# -*- coding:utf-8 -*-
# __author__ : "张百科"
# Date: 2020/8/13 10:54
# File: common.py
# IDE: PyCharm

import time, datetime

prefix='zyy_'

def get_file_path(instance, filename):
    folder = instance.enterprise.name
    filetype=instance.get_case_type_display()
    print(filetype)
    return '%s/%s/%s' % (filetype,folder,filename)

def get_car_file_path(instance, filename):
    folder = instance.car.car_no
    filetype=instance.get_case_type_display()
    print(filetype)
    return '%s/%s/%s' % (filetype,folder,filename)

def get_check_file_path(location_name,username):

    filetype='巡检资料'
    datePath=datetime.datetime.now().strftime('%Y-%m-%d')
    folder=location_name
    return '%s/%s/%s/%s' % (filetype,folder,datePath,username)

def GetTimestamp():
    now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    timeArray = time.strptime(now, "%Y-%m-%d %H:%M:%S")
    timestamp = int(time.mktime(timeArray))
    return timestamp
